// pages/classification/classification.js
var SERVER_PATH = "http://127.0.0.1:8000/classify";//定义服务器地址

Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeIndex:0,
    VerticalNavTop: 0,
    TabCur: 0,
  },

  onLoad: function (options) {
    var that = this;
    //调用getSystemInfo APi获取到用户的手机屏幕高度，动态设置scroll-view的高度

    wx.request({
      url: SERVER_PATH,
      success: function (res) {
        console.log(res);//打印出返回的数据
        that.setData({
          result:res.data
        })
      },
    }),
    // 还有缺陷，代改进
    wx.getSystemInfo({
      success (res) {
        
        // var heightleft = (res.windowHeight*2);
        var height = (res.windowHeight*2);
       
        that.setData({
          phoneHeight:height,
        })
      }
    })
  },

  //随着滚动动态设置左侧边栏的选中态
  showActive:function (e) {
    //方法欠佳，还需改进
    var index = parseInt( e.detail.scrollTop/116);
    this.setData({
      activeIndex: index
     })
  },
  // 侧边栏的点击事件
  change:function (e){
    var that = this;
    that.setData({
      VerticalNavTop: (e.currentTarget.dataset.index - 1) * 50,
      activeIndex: e.currentTarget.dataset.index,
      TabCur: e.currentTarget.dataset.id,
    })
  },

  //>点击事件
  bandan: function (event){
    var title_id = event.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/index/bangdan/bangdan?bangdanId='+ title_id,
      })
    },
  worklist: function (event) {
    var title_id = event.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/index/bangdan/bangdan?bangdanId=' + title_id,
    })
  },
})